﻿Imports System.Data
Imports System.Data.SqlClient
Public Class Frm_Avoc_Bure_ville

    Private Sub Frm_Avoc_Bure_ville_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Frm_Avoc_Bure.Enabled = True
        Frm_Clients.Enabled = True
        Frm_Adver.Enabled = True
        Frm_Avoc_Adv.Enabled = True
        Frm_chohoud.Enabled = True
        Frm_Avoc_Clien.Enabled = True
        Frm_Avoc_mokhabara.Enabled = True

        Frm_khabir.Enabled = True
        Frm_sahib_maktab.Enabled = True
        Frm_mowadafin.Enabled = True

        Partager.com_ville(Frm_Avoc_Bure.comb_ville, "Comb_Ville", "Ville")
        Partager.com_ville(Frm_Clients.comb_ville, "Comb_Ville", "Ville")
        Partager.com_ville(Frm_Adver.comb_ville, "Comb_Ville", "Ville")
        Partager.com_ville(Frm_Avoc_Adv.comb_ville, "Comb_Ville", "Ville")
        Partager.com_ville(Frm_chohoud.comb_ville, "Comb_Ville", "Ville")
        Partager.com_ville(Frm_Avoc_Clien.comb_ville, "Comb_Ville", "Ville")
        Partager.com_ville(Frm_Avoc_mokhabara.comb_ville, "Comb_Ville", "Ville")
        Partager.com_ville(Frm_sahib_maktab.comb_ville, "Comb_Ville", "Ville")
        Partager.com_ville(Frm_mowadafin.comb_ville, "Comb_Ville", "Ville")
        Partager.com_ville(Frm_khabir.comb_ville, "Comb_Ville", "Ville")
    End Sub

    Private Sub Frm_Avoc_Bure_ville_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txt_ville.Select()
        Partager.RemplirList(List_ville, "Comb_Ville", "Ville")
    End Sub

    Private Sub btn_ajout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ajout.Click
        If (txt_ville.Text <> "") Then
            Try
                Partager.cmd = New SqlCommand("insert into Comb_Ville (Ville) values (@vil)", Partager.con)
                Partager.cmd.Parameters.Add("@vil", SqlDbType.VarChar).Value = txt_ville.Text
                Partager.Open()
                Partager.cmd.ExecuteNonQuery()
                Partager.Close()
                Partager.RemplirList(List_ville, "Comb_Ville", "Ville")
                txt_ville.Clear()
                txt_ville.Select()
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Exclamation)
                Partager.Close()
            End Try
        End If
    End Sub

    Private Sub btn_supp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_supp.Click
        Partager.DeleteFromList(List_ville, "Comb_Ville", "Ville", txt_ville)
    End Sub
End Class